package com.dge.app.utils;

import ohos.agp.components.Component;
import ohos.agp.utils.Point;
import ohos.agp.utils.Rect;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

public class Utils {
    static final HiLogLabel label = new HiLogLabel(HiLog.DEBUG, 0x00201, "Utils"); // MY_MODULE=0x00201

    public static boolean isInComponentArea(Component component, Point point) {
        int pointX = (int) point.getPointX();
        int pointY = (int) point.getPointY();
        HiLog.info(label, "isInViewArea pointX = " + pointX + ", pointY =" + pointY);
        int x = component.getPivot().getPointXToInt();
        int y = component.getPivot().getPointYToInt();
        Rect r = new Rect(x, y, x + component.getWidth(), y + component.getHeight());
        HiLog.info(label, "isInViewArea left " + r.left + "right " + r.right);
        return pointX > r.left && pointX < r.right && pointY > r.top && pointY < r.bottom;
    }

}
